// $ANTLR 3.1.3 Mar 18, 2009 10:09:25 vslTree.g 2009-12-14 19:15:15

import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

public class vslTree extends TreeParser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "IMAGINERY_TOKEN", "PROG", "CORPS", "FCALL_S", "BLOCK", "FCALL", "ARDEC", "PARAM", "ARRAY", "ARELEM", "INST", "DEC", "FUNC_KW", "IDENT", "PG", "PD", "PROTO_KW", "INT_KW", "VOID_KW", "VIRG", "CG", "CD", "ASSIGN_KW", "RETURN_KW", "PRINT_KW", "READ_KW", "IF_KW", "THEN_KW", "ELSE_KW", "FI_KW", "WHILE_KW", "DO_KW", "OD_KW", "AG", "AD", "PLUS", "MOINS", "MUL", "DIV", "INTEGER", "TEXT", "WS", "COMMENT", "LETTER", "DIGIT", "ASCII"
    };
    public static final int DEC=15;
    public static final int LETTER=47;
    public static final int OD_KW=36;
    public static final int PARAM=11;
    public static final int EOF=-1;
    public static final int INT_KW=21;
    public static final int INST=14;
    public static final int MOINS=40;
    public static final int PROG=5;
    public static final int RETURN_KW=27;
    public static final int IMAGINERY_TOKEN=4;
    public static final int ARELEM=13;
    public static final int IF_KW=30;
    public static final int ARDEC=10;
    public static final int VIRG=23;
    public static final int AD=38;
    public static final int IDENT=17;
    public static final int PLUS=39;
    public static final int FI_KW=33;
    public static final int AG=37;
    public static final int DIGIT=48;
    public static final int ASSIGN_KW=26;
    public static final int COMMENT=46;
    public static final int ARRAY=12;
    public static final int READ_KW=29;
    public static final int INTEGER=43;
    public static final int FCALL=9;
    public static final int DO_KW=35;
    public static final int FUNC_KW=16;
    public static final int ELSE_KW=32;
    public static final int TEXT=44;
    public static final int MUL=41;
    public static final int THEN_KW=31;
    public static final int WS=45;
    public static final int PROTO_KW=20;
    public static final int WHILE_KW=34;
    public static final int CORPS=6;
    public static final int BLOCK=8;
    public static final int ASCII=49;
    public static final int FCALL_S=7;
    public static final int CG=24;
    public static final int DIV=42;
    public static final int CD=25;
    public static final int PRINT_KW=28;
    public static final int PD=19;
    public static final int PG=18;
    public static final int VOID_KW=22;

    // delegates
    // delegators


        public vslTree(TreeNodeStream input) {
            this(input, new RecognizerSharedState());
        }
        public vslTree(TreeNodeStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        

    public String[] getTokenNames() { return vslTree.tokenNames; }
    public String getGrammarFileName() { return "vslTree.g"; }


    			TableSymboles tabSymboles = new TableSymboles();
    			boolean Fonction = false;
    		


    // $ANTLR start "program"
    // vslTree.g:28:1: program returns [Code c] : ^( PROG (u= unite )+ ) ;
    public final Code program() throws RecognitionException {
        Code c = null;

        Code u = null;


        c=new Code();
        try {
            // vslTree.g:30:3: ( ^( PROG (u= unite )+ ) )
            // vslTree.g:30:6: ^( PROG (u= unite )+ )
            {
            match(input,PROG,FOLLOW_PROG_in_program72); 

            match(input, Token.DOWN, null); 
            // vslTree.g:30:13: (u= unite )+
            int cnt1=0;
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==FUNC_KW||LA1_0==PROTO_KW) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // vslTree.g:30:14: u= unite
            	    {
            	    pushFollow(FOLLOW_unite_in_program77);
            	    u=unite();

            	    state._fsp--;

            	    	
            	    				if(u == null)
            	    				{
            	    					System.err.println("On ne trouve pas d'unité dans le programme, il en faut au moin une"); 
            	    					System.exit(1); 
            	    				}
            	    				else
            	    				{
            	    				c.append(u); 
            	    				tabSymboles.Dump(); 
            	    				}
            	    			

            	    }
            	    break;

            	default :
            	    if ( cnt1 >= 1 ) break loop1;
                        EarlyExitException eee =
                            new EarlyExitException(1, input);
                        throw eee;
                }
                cnt1++;
            } while (true);


            match(input, Token.UP, null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "program"


    // $ANTLR start "unite"
    // vslTree.g:46:1: unite returns [Code c] : ( ^( FUNC_KW t1= type id1= IDENT par1= param_list ^( CORPS s= statement ) ) | ^( PROTO_KW t2= type id2= IDENT p2= param_list ) );
    public final Code unite() throws RecognitionException {
        Code c = null;

        CommonTree id1=null;
        CommonTree id2=null;
        Type t1 = null;

        Code par1 = null;

        Code s = null;

        Type t2 = null;

        Code p2 = null;


        c = new Code();
        try {
            // vslTree.g:48:3: ( ^( FUNC_KW t1= type id1= IDENT par1= param_list ^( CORPS s= statement ) ) | ^( PROTO_KW t2= type id2= IDENT p2= param_list ) )
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==FUNC_KW) ) {
                alt2=1;
            }
            else if ( (LA2_0==PROTO_KW) ) {
                alt2=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 2, 0, input);

                throw nvae;
            }
            switch (alt2) {
                case 1 :
                    // vslTree.g:48:5: ^( FUNC_KW t1= type id1= IDENT par1= param_list ^( CORPS s= statement ) )
                    {
                    match(input,FUNC_KW,FOLLOW_FUNC_KW_in_unite114); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_type_in_unite118);
                    t1=type();

                    state._fsp--;

                    id1=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_unite122); 
                    pushFollow(FOLLOW_param_list_in_unite126);
                    par1=param_list();

                    state._fsp--;

                    match(input,CORPS,FOLLOW_CORPS_in_unite129); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_statement_in_unite133);
                    s=statement();

                    state._fsp--;


                    match(input, Token.UP, null); 

                    match(input, Token.UP, null); 

                    				Fonction = true; 
                    				Code cod;
                    				Tokatt tok;
                    				Tokatt label;
                    				Inst3a in;
                    				cod = new Code();
                    				tok = tabSymboles.Lookup(id1.getText());
                    				label = new Tokatt(id1.getText(), t1);

                    				if(tok !=null && tok.scope !=0)
                    				{	
                    					System.err.println("variable déja existante");
                    					System.exit(1); 
                    				}
                    				else if(tok !=null && tok.scope == 0)
                    				{	
                    					in = new Inst3a(Inst3a.TAC_LABEL, label, null, null);
                    					cod.append(new Code(in));
                    					in = new Inst3a(Inst3a.TAC_BEGINFUNC,null,null,null);
                    					cod.append(new Code(in));
                    					cod.append(par1);
                    					cod.append(s);
                    					in = new Inst3a(Inst3a.TAC_ENDFUNC,null,null,null);
                    					cod.append(new Code(in));
                    				}
                    				else
                    				{	
                    					tok = new Tokatt(t1, id1.getText(), 0);
                    					tabSymboles.Insert(id1.getText(), tok);
                    					in = new Inst3a(Inst3a.TAC_LABEL, label, null, null);
                    					cod.append(new Code(in));
                    					in = new Inst3a(Inst3a.TAC_BEGINFUNC,null,null,null);
                    					cod.append(new Code(in));
                    					cod.append(par1);
                    					cod.append(s);
                    					in = new Inst3a(Inst3a.TAC_ENDFUNC,null,null,null);
                    					cod.append(new Code(in));
                    				}
                    			c = cod;				
                    			

                    }
                    break;
                case 2 :
                    // vslTree.g:90:5: ^( PROTO_KW t2= type id2= IDENT p2= param_list )
                    {
                    match(input,PROTO_KW,FOLLOW_PROTO_KW_in_unite147); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_type_in_unite151);
                    t2=type();

                    state._fsp--;

                    id2=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_unite155); 
                    pushFollow(FOLLOW_param_list_in_unite159);
                    p2=param_list();

                    state._fsp--;


                    match(input, Token.UP, null); 

                    				Fonction = false;
                    				Code cod;
                    				Tokatt tok;
                    				
                    				cod = new Code();
                    				tok = tabSymboles.Lookup(id2.getText());

                    				if(tok !=null && tok.scope !=0)
                    				{
                    					System.err.println("variable déja existante");
                    					System.exit(1); 
                    				}
                    				else if(tok !=null && tok.scope == 0)
                    				{
                    					return c;
                    				}
                    				else
                    				{
                    					tok = new Tokatt(t2, id2.getText(), 0);
                    					tabSymboles.Insert(id2.getText(), tok);
                    				}
                    			c = cod;				
                    			

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "unite"


    // $ANTLR start "type"
    // vslTree.g:117:1: type returns [Type t] : ( INT_KW | VOID_KW );
    public final Type type() throws RecognitionException {
        Type t = null;

        t = null;
        try {
            // vslTree.g:119:3: ( INT_KW | VOID_KW )
            int alt3=2;
            int LA3_0 = input.LA(1);

            if ( (LA3_0==INT_KW) ) {
                alt3=1;
            }
            else if ( (LA3_0==VOID_KW) ) {
                alt3=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 3, 0, input);

                throw nvae;
            }
            switch (alt3) {
                case 1 :
                    // vslTree.g:119:5: INT_KW
                    {
                    match(input,INT_KW,FOLLOW_INT_KW_in_type188); 

                    				t = TypeSystem.T_integer;
                    			

                    }
                    break;
                case 2 :
                    // vslTree.g:123:5: VOID_KW
                    {
                    match(input,VOID_KW,FOLLOW_VOID_KW_in_type199); 

                    				t = TypeSystem.T_void;
                    			

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return t;
    }
    // $ANTLR end "type"


    // $ANTLR start "param_list"
    // vslTree.g:129:1: param_list returns [Code c] : ^( PARAM (p= param )* ) ;
    public final Code param_list() throws RecognitionException {
        Code c = null;

        Code p = null;


        c = new Code();
        try {
            // vslTree.g:131:3: ( ^( PARAM (p= param )* ) )
            // vslTree.g:131:5: ^( PARAM (p= param )* )
            {
            match(input,PARAM,FOLLOW_PARAM_in_param_list229); 

            if ( input.LA(1)==Token.DOWN ) {
                match(input, Token.DOWN, null); 
                // vslTree.g:131:14: (p= param )*
                loop4:
                do {
                    int alt4=2;
                    int LA4_0 = input.LA(1);

                    if ( (LA4_0==ARRAY||LA4_0==IDENT) ) {
                        alt4=1;
                    }


                    switch (alt4) {
                	case 1 :
                	    // vslTree.g:131:14: p= param
                	    {
                	    pushFollow(FOLLOW_param_in_param_list233);
                	    p=param();

                	    state._fsp--;


                	    }
                	    break;

                	default :
                	    break loop4;
                    }
                } while (true);


                match(input, Token.UP, null); 
            }
            	
            				if(p==null)
            				{
            					return c;
            				}
            				else
            				{
            					c.append(p);
            				}
            			

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "param_list"


    // $ANTLR start "param"
    // vslTree.g:144:1: param returns [Code c] : (id= IDENT | ^( ARRAY id= IDENT ) );
    public final Code param() throws RecognitionException {
        Code c = null;

        CommonTree id=null;

        c = new Code();
        try {
            // vslTree.g:146:3: (id= IDENT | ^( ARRAY id= IDENT ) )
            int alt5=2;
            int LA5_0 = input.LA(1);

            if ( (LA5_0==IDENT) ) {
                alt5=1;
            }
            else if ( (LA5_0==ARRAY) ) {
                alt5=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 5, 0, input);

                throw nvae;
            }
            switch (alt5) {
                case 1 :
                    // vslTree.g:146:5: id= IDENT
                    {
                    id=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_param265); 

                    				Code cod;
                    				Inst3a in;
                    				Tokatt tok;
                    				Tokatt param;
                    			
                    				cod = new Code();
                    				tok = tabSymboles.Lookup(id.getText());
                    				
                    				if (Fonction == true)
                    				{
                    					if(tok!=null)
                    					{
                    						System.err.println("variable déja existante");
                    						System.exit(1);
                    					}
                    					else
                    					{
                    						param = new Tokatt(TypeSystem.T_integer, id.getText(), 0);
                    						tabSymboles.Insert(id.getText(), param);
                    						in = new Inst3a(Inst3a.TAC_VAR, param, null, null);
                    						cod.append(new Code(in));
                    					}
                    				}
                    				else 
                    				{
                    					if(tok!=null)
                    					{
                    						System.err.println("variable déja existante");
                    						System.exit(1);
                    					}
                    					else
                    					{
                    						param = new Tokatt(TypeSystem.T_integer, id.getText(), 0);
                    						tabSymboles.Insert(id.getText(), param);
                    					}									
                    				}
                    				c = cod;
                    			

                    }
                    break;
                case 2 :
                    // vslTree.g:186:12: ^( ARRAY id= IDENT )
                    {
                    match(input,ARRAY,FOLLOW_ARRAY_in_param284); 

                    match(input, Token.DOWN, null); 
                    id=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_param288); 

                    match(input, Token.UP, null); 

                    				Code cod;
                    				Inst3a in;			
                    				Tokatt tok;
                    				Tokatt param;
                    				String iden = id.getText();
                    				TypeArray typeTab = new TypeArray(TypeSystem.T_integer, 0);
                    				
                    				tok = tabSymboles.Lookup(iden);
                    				cod = new Code();

                    				if (Fonction == true)
                    				{
                    					if(tok!=null)
                    					{
                    						System.err.println("tableau deja existant");
                    						System.exit(1);
                    					}
                    					else
                    					{

                    						param = new Tokatt(typeTab,iden,0);
                    						tabSymboles.Insert(iden, tok);
                    						in = new Inst3a(Inst3a.TAC_VAR, param, null, null);
                    						cod.append(new Code(in));
                    					}
                    				}
                    				else 
                    				{
                    					if(tok!=null)
                    					{
                    						System.err.println("tableau déja existant");
                    						System.exit(1);
                    					}
                    					else
                    					{				
                    						param = new Tokatt(typeTab,iden,0);
                    						tabSymboles.Insert(id.getText(), param);
                    					}	
                    				}								
                    				c = cod;
                    			

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "param"


    // $ANTLR start "statement"
    // vslTree.g:233:1: statement returns [Code c] : ( ^( ASSIGN_KW id= IDENT exp= expression ) | ^( ASSIGN_KW tab= tab_elem exp= expression ) | ^( RETURN_KW exp= expression ) | ^( PRINT_KW p= print_list ) | ^( READ_KW r= read_list ) | ^( IF_KW exp1= expression s1= statement (s2= statement )? ) | ^( WHILE_KW expr= expression s= statement ) | ^( FCALL_S id= IDENT arg= argument_list ) | b= block );
    public final Code statement() throws RecognitionException {
        Code c = null;

        CommonTree id=null;
        Expratt exp = null;

        TableAtt tab = null;

        Code p = null;

        Code r = null;

        Expratt exp1 = null;

        Code s1 = null;

        Code s2 = null;

        Expratt expr = null;

        Code s = null;

        Expratt arg = null;

        Code b = null;


        c = new Code();
        try {
            // vslTree.g:235:3: ( ^( ASSIGN_KW id= IDENT exp= expression ) | ^( ASSIGN_KW tab= tab_elem exp= expression ) | ^( RETURN_KW exp= expression ) | ^( PRINT_KW p= print_list ) | ^( READ_KW r= read_list ) | ^( IF_KW exp1= expression s1= statement (s2= statement )? ) | ^( WHILE_KW expr= expression s= statement ) | ^( FCALL_S id= IDENT arg= argument_list ) | b= block )
            int alt7=9;
            alt7 = dfa7.predict(input);
            switch (alt7) {
                case 1 :
                    // vslTree.g:235:5: ^( ASSIGN_KW id= IDENT exp= expression )
                    {
                    match(input,ASSIGN_KW,FOLLOW_ASSIGN_KW_in_statement321); 

                    match(input, Token.DOWN, null); 
                    id=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_statement325); 
                    pushFollow(FOLLOW_expression_in_statement329);
                    exp=expression();

                    state._fsp--;


                    match(input, Token.UP, null); 
                    	
                    				String nameIdent;
                    				Tokatt rechercheIdent;
                    				Inst3a i;
                    				Tokatt temp = SymbDistrib.newTemp();

                    				nameIdent = id.getText();
                    				rechercheIdent = tabSymboles.Lookup(nameIdent);

                    				if(rechercheIdent == null || rechercheIdent.scope != tabSymboles.getScope())
                    				{
                    					System.err.println("Ident pas déclaré");
                    					System.exit(1);
                    				}
                    				else
                    				{	
                    					i = new Inst3a(Inst3a.TAC_VAR, temp, null, null);
                    					c.append(new Code(i));	
                    					i = new Inst3a(Inst3a.TAC_COPY, temp, exp.place, null);
                    					c.append(new Code(i));
                    					i = new Inst3a(Inst3a.TAC_COPY, rechercheIdent, temp, null);
                    					c.append(new Code(i));
                    				}
                    			

                    }
                    break;
                case 2 :
                    // vslTree.g:260:5: ^( ASSIGN_KW tab= tab_elem exp= expression )
                    {
                    match(input,ASSIGN_KW,FOLLOW_ASSIGN_KW_in_statement342); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_tab_elem_in_statement346);
                    tab=tab_elem();

                    state._fsp--;

                    pushFollow(FOLLOW_expression_in_statement350);
                    exp=expression();

                    state._fsp--;


                    match(input, Token.UP, null); 

                    				Inst3a in;

                    				if(exp==null)
                    				{
                    					System.err.println("il n'y a pas d'expression a assigner");
                    					System.exit(1);
                    				}
                    				else
                    				{
                    				c.append(exp.code);
                    				in = new Inst3a(Inst3a.TAC_VARTAB, tab.ident , tab.expression , exp.place);
                    				c.append(new Code(in));
                    				}
                    				
                    			

                    }
                    break;
                case 3 :
                    // vslTree.g:277:5: ^( RETURN_KW exp= expression )
                    {
                    match(input,RETURN_KW,FOLLOW_RETURN_KW_in_statement364); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expression_in_statement368);
                    exp=expression();

                    state._fsp--;


                    match(input, Token.UP, null); 

                    				Inst3a in;
                    				
                    				in = new Inst3a(Inst3a.TAC_RETURN, exp.place, null, null);
                    				c.append(new Code(in));
                    			

                    }
                    break;
                case 4 :
                    // vslTree.g:284:5: ^( PRINT_KW p= print_list )
                    {
                    match(input,PRINT_KW,FOLLOW_PRINT_KW_in_statement381); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_print_list_in_statement385);
                    p=print_list();

                    state._fsp--;


                    match(input, Token.UP, null); 

                    				c=p;
                    			

                    }
                    break;
                case 5 :
                    // vslTree.g:288:5: ^( READ_KW r= read_list )
                    {
                    match(input,READ_KW,FOLLOW_READ_KW_in_statement398); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_read_list_in_statement402);
                    r=read_list();

                    state._fsp--;


                    match(input, Token.UP, null); 

                    				c=r;
                    			

                    }
                    break;
                case 6 :
                    // vslTree.g:292:5: ^( IF_KW exp1= expression s1= statement (s2= statement )? )
                    {
                    match(input,IF_KW,FOLLOW_IF_KW_in_statement415); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expression_in_statement419);
                    exp1=expression();

                    state._fsp--;

                    pushFollow(FOLLOW_statement_in_statement423);
                    s1=statement();

                    state._fsp--;

                    // vslTree.g:292:42: (s2= statement )?
                    int alt6=2;
                    int LA6_0 = input.LA(1);

                    if ( ((LA6_0>=FCALL_S && LA6_0<=BLOCK)||(LA6_0>=ASSIGN_KW && LA6_0<=IF_KW)||LA6_0==WHILE_KW) ) {
                        alt6=1;
                    }
                    switch (alt6) {
                        case 1 :
                            // vslTree.g:292:43: s2= statement
                            {
                            pushFollow(FOLLOW_statement_in_statement428);
                            s2=statement();

                            state._fsp--;


                            }
                            break;

                    }


                    match(input, Token.UP, null); 
                    				
                    				Type ty;
                    				ty = TypeSystem.CheckInt(exp1.type);
                    				if(ty == TypeSystem.T_integer)

                    				{
                    					c = Code.genIf(exp1, s1, s2);
                    				}
                    				else 
                    				{
                    					System.err.println("Probléme de type dans le traitement de statement"); 
                    					System.exit(1);
                    				}
                    			

                    }
                    break;
                case 7 :
                    // vslTree.g:307:5: ^( WHILE_KW expr= expression s= statement )
                    {
                    match(input,WHILE_KW,FOLLOW_WHILE_KW_in_statement443); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expression_in_statement447);
                    expr=expression();

                    state._fsp--;

                    pushFollow(FOLLOW_statement_in_statement451);
                    s=statement();

                    state._fsp--;


                    match(input, Token.UP, null); 
                    	
                    				Type ty;

                    				ty = TypeSystem.CheckInt(expr.type);
                    				if(ty == TypeSystem.T_integer)
                    				{
                    					c = Code.genWhile(expr, s);
                    				}
                    				else 
                    				{
                    					System.err.println("Probléme de type dans le traitement de statement"); 
                    					System.exit(1);
                    				}
                    			

                    }
                    break;
                case 8 :
                    // vslTree.g:323:5: ^( FCALL_S id= IDENT arg= argument_list )
                    {
                    match(input,FCALL_S,FOLLOW_FCALL_S_in_statement468); 

                    match(input, Token.DOWN, null); 
                    id=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_statement472); 
                    pushFollow(FOLLOW_argument_list_in_statement476);
                    arg=argument_list();

                    state._fsp--;


                    match(input, Token.UP, null); 
                    	
                    				Code cod;
                    				Inst3a in;
                    				Tokatt tok;
                    			
                    				cod = new Code();

                    				if(tabSymboles.Lookup(id.getText())==null)
                    				{
                    					System.err.println("La fonction n'existe pas");
                    					System.exit(1);
                    				}
                    				else
                    				{
                    					tok = new Tokatt(id.getText());
                    					cod = new Code();

                    					in = new Inst3a(Inst3a.TAC_CALL, tok, null, null);
                    					cod.append(new Code(in));
                    					cod.append(arg.code);
                    				}
                    			c = cod;
                    			

                    }
                    break;
                case 9 :
                    // vslTree.g:347:5: b= block
                    {
                    pushFollow(FOLLOW_block_in_statement490);
                    b=block();

                    state._fsp--;

                     c = b;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "statement"


    // $ANTLR start "block"
    // vslTree.g:351:1: block returns [Code c] : ( ^( BLOCK dec= declaration (s= suit_inst )+ ) | ^( BLOCK (s= suit_inst )+ ) );
    public final Code block() throws RecognitionException {
        Code c = null;

        Code dec = null;

        Code s = null;


        c=new Code();
        try {
            // vslTree.g:353:3: ( ^( BLOCK dec= declaration (s= suit_inst )+ ) | ^( BLOCK (s= suit_inst )+ ) )
            int alt10=2;
            int LA10_0 = input.LA(1);

            if ( (LA10_0==BLOCK) ) {
                int LA10_1 = input.LA(2);

                if ( (LA10_1==DOWN) ) {
                    int LA10_2 = input.LA(3);

                    if ( (LA10_2==DEC) ) {
                        alt10=1;
                    }
                    else if ( (LA10_2==INST) ) {
                        alt10=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 10, 2, input);

                        throw nvae;
                    }
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 10, 1, input);

                    throw nvae;
                }
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 10, 0, input);

                throw nvae;
            }
            switch (alt10) {
                case 1 :
                    // vslTree.g:353:5: ^( BLOCK dec= declaration (s= suit_inst )+ )
                    {
                    match(input,BLOCK,FOLLOW_BLOCK_in_block520); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_declaration_in_block524);
                    dec=declaration();

                    state._fsp--;

                    // vslTree.g:353:29: (s= suit_inst )+
                    int cnt8=0;
                    loop8:
                    do {
                        int alt8=2;
                        int LA8_0 = input.LA(1);

                        if ( (LA8_0==INST) ) {
                            alt8=1;
                        }


                        switch (alt8) {
                    	case 1 :
                    	    // vslTree.g:353:30: s= suit_inst
                    	    {
                    	    pushFollow(FOLLOW_suit_inst_in_block529);
                    	    s=suit_inst();

                    	    state._fsp--;


                    	    }
                    	    break;

                    	default :
                    	    if ( cnt8 >= 1 ) break loop8;
                                EarlyExitException eee =
                                    new EarlyExitException(8, input);
                                throw eee;
                        }
                        cnt8++;
                    } while (true);


                    match(input, Token.UP, null); 

                    				tabSymboles.Enter_Scope();				
                    				c = Code.genBlock(dec,s);
                    				tabSymboles.Leave_Scope();
                    			

                    }
                    break;
                case 2 :
                    // vslTree.g:359:5: ^( BLOCK (s= suit_inst )+ )
                    {
                    match(input,BLOCK,FOLLOW_BLOCK_in_block544); 

                    match(input, Token.DOWN, null); 
                    // vslTree.g:359:13: (s= suit_inst )+
                    int cnt9=0;
                    loop9:
                    do {
                        int alt9=2;
                        int LA9_0 = input.LA(1);

                        if ( (LA9_0==INST) ) {
                            alt9=1;
                        }


                        switch (alt9) {
                    	case 1 :
                    	    // vslTree.g:359:14: s= suit_inst
                    	    {
                    	    pushFollow(FOLLOW_suit_inst_in_block549);
                    	    s=suit_inst();

                    	    state._fsp--;

                    	    c.append(s);

                    	    }
                    	    break;

                    	default :
                    	    if ( cnt9 >= 1 ) break loop9;
                                EarlyExitException eee =
                                    new EarlyExitException(9, input);
                                throw eee;
                        }
                        cnt9++;
                    } while (true);


                    match(input, Token.UP, null); 

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "block"


    // $ANTLR start "tab_elem"
    // vslTree.g:363:1: tab_elem returns [TableAtt t] : ^( ARELEM id= IDENT exp= expression ) ;
    public final TableAtt tab_elem() throws RecognitionException {
        TableAtt t = null;

        CommonTree id=null;
        Expratt exp = null;


        t=null;
        try {
            // vslTree.g:365:3: ( ^( ARELEM id= IDENT exp= expression ) )
            // vslTree.g:365:6: ^( ARELEM id= IDENT exp= expression )
            {
            match(input,ARELEM,FOLLOW_ARELEM_in_tab_elem581); 

            match(input, Token.DOWN, null); 
            id=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_tab_elem585); 
            pushFollow(FOLLOW_expression_in_tab_elem589);
            exp=expression();

            state._fsp--;


            match(input, Token.UP, null); 

            				Inst3a in;
            				Tokatt tok;
            				Code c;
            				Tokatt ident;
            				Expratt expr;

            				tok = SymbDistrib.newTemp();
            				c = new Code();
            				ident = tabSymboles.Lookup(id.getText());

            	
            				if(ident==null && ident.scope != tabSymboles.getScope())
            	
            				{
            					System.err.println("tableau pas encore déclaré");
            					System.exit(1);
            				}
            				else
            				{	
            					in = new Inst3a(Inst3a.TAC_VAR, tok, null, null);
            					c.append(new Code(in));
            					in = new Inst3a(Inst3a.TAC_TABVAR, tok, tabSymboles.Lookup(id.getText()), exp.place);
            					c.append(new Code(in));
            				}
            				expr = new Expratt(TypeSystem.T_integer, c, tok);
            				t = new TableAtt(ident,exp.place, expr);
            			

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return t;
    }
    // $ANTLR end "tab_elem"


    // $ANTLR start "suit_inst"
    // vslTree.g:396:1: suit_inst returns [Code c] : ^( INST (s= statement )+ ) ;
    public final Code suit_inst() throws RecognitionException {
        Code c = null;

        Code s = null;


        c = new Code();
        try {
            // vslTree.g:398:3: ( ^( INST (s= statement )+ ) )
            // vslTree.g:398:5: ^( INST (s= statement )+ )
            {
            match(input,INST,FOLLOW_INST_in_suit_inst622); 

            match(input, Token.DOWN, null); 
            // vslTree.g:398:12: (s= statement )+
            int cnt11=0;
            loop11:
            do {
                int alt11=2;
                int LA11_0 = input.LA(1);

                if ( ((LA11_0>=FCALL_S && LA11_0<=BLOCK)||(LA11_0>=ASSIGN_KW && LA11_0<=IF_KW)||LA11_0==WHILE_KW) ) {
                    alt11=1;
                }


                switch (alt11) {
            	case 1 :
            	    // vslTree.g:398:14: s= statement
            	    {
            	    pushFollow(FOLLOW_statement_in_suit_inst630);
            	    s=statement();

            	    state._fsp--;

            	     c.append(s); 

            	    }
            	    break;

            	default :
            	    if ( cnt11 >= 1 ) break loop11;
                        EarlyExitException eee =
                            new EarlyExitException(11, input);
                        throw eee;
                }
                cnt11++;
            } while (true);


            match(input, Token.UP, null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "suit_inst"


    // $ANTLR start "expression"
    // vslTree.g:402:1: expression returns [Expratt exp] : ( ^( PLUS exp1= expression exp2= expression ) | ^( MOINS exp1= expression exp2= expression ) | ^( MUL exp1= expression exp2= expression ) | ^( DIV exp1= expression exp2= expression ) | e= primaire );
    public final Expratt expression() throws RecognitionException {
        Expratt exp = null;

        Expratt exp1 = null;

        Expratt exp2 = null;

        Expratt e = null;


        exp = null;
        try {
            // vslTree.g:404:3: ( ^( PLUS exp1= expression exp2= expression ) | ^( MOINS exp1= expression exp2= expression ) | ^( MUL exp1= expression exp2= expression ) | ^( DIV exp1= expression exp2= expression ) | e= primaire )
            int alt12=5;
            switch ( input.LA(1) ) {
            case PLUS:
                {
                alt12=1;
                }
                break;
            case MOINS:
                {
                alt12=2;
                }
                break;
            case MUL:
                {
                alt12=3;
                }
                break;
            case DIV:
                {
                alt12=4;
                }
                break;
            case FCALL:
            case ARELEM:
            case IDENT:
            case INTEGER:
                {
                alt12=5;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 12, 0, input);

                throw nvae;
            }

            switch (alt12) {
                case 1 :
                    // vslTree.g:404:5: ^( PLUS exp1= expression exp2= expression )
                    {
                    match(input,PLUS,FOLLOW_PLUS_in_expression661); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expression_in_expression665);
                    exp1=expression();

                    state._fsp--;

                    pushFollow(FOLLOW_expression_in_expression670);
                    exp2=expression();

                    state._fsp--;


                    match(input, Token.UP, null); 
                    Type ty = TypeSystem.CheckBinOp(exp1.type, exp2.type);
                    				  Tokatt temp = SymbDistrib.newTemp();
                    				  Code cod = Code.genBinOp(Inst3a.TAC_ADD, exp1, exp2, temp);
                    				  exp = new Expratt(ty, cod, temp);


                    }
                    break;
                case 2 :
                    // vslTree.g:410:5: ^( MOINS exp1= expression exp2= expression )
                    {
                    match(input,MOINS,FOLLOW_MOINS_in_expression683); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expression_in_expression687);
                    exp1=expression();

                    state._fsp--;

                    pushFollow(FOLLOW_expression_in_expression691);
                    exp2=expression();

                    state._fsp--;


                    match(input, Token.UP, null); 
                    Type ty = TypeSystem.CheckBinOp(exp1.type, exp2.type);
                    				  Tokatt temp = SymbDistrib.newTemp();
                    				  Code cod = Code.genBinOp(Inst3a.TAC_SUB, exp1, exp2, temp);
                    				  exp = new Expratt(ty, cod, temp);


                    }
                    break;
                case 3 :
                    // vslTree.g:416:5: ^( MUL exp1= expression exp2= expression )
                    {
                    match(input,MUL,FOLLOW_MUL_in_expression704); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expression_in_expression708);
                    exp1=expression();

                    state._fsp--;

                    pushFollow(FOLLOW_expression_in_expression713);
                    exp2=expression();

                    state._fsp--;


                    match(input, Token.UP, null); 
                    Type ty = TypeSystem.CheckBinOp(exp1.type, exp2.type);
                    				  Tokatt temp = SymbDistrib.newTemp();
                    				  Code cod = Code.genBinOp(Inst3a.TAC_MUL, exp1, exp2, temp);
                    				  exp = new Expratt(ty, cod, temp);


                    }
                    break;
                case 4 :
                    // vslTree.g:422:5: ^( DIV exp1= expression exp2= expression )
                    {
                    match(input,DIV,FOLLOW_DIV_in_expression726); 

                    match(input, Token.DOWN, null); 
                    pushFollow(FOLLOW_expression_in_expression730);
                    exp1=expression();

                    state._fsp--;

                    pushFollow(FOLLOW_expression_in_expression735);
                    exp2=expression();

                    state._fsp--;


                    match(input, Token.UP, null); 
                    Type ty = TypeSystem.CheckBinOp(exp1.type, exp2.type);
                    				  Tokatt temp = SymbDistrib.newTemp();
                    				  Code cod = Code.genBinOp(Inst3a.TAC_DIV, exp1, exp2, temp);
                    				  exp = new Expratt(ty, cod, temp);


                    }
                    break;
                case 5 :
                    // vslTree.g:428:5: e= primaire
                    {
                    pushFollow(FOLLOW_primaire_in_expression751);
                    e=primaire();

                    state._fsp--;

                    exp=e;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return exp;
    }
    // $ANTLR end "expression"


    // $ANTLR start "primaire"
    // vslTree.g:433:1: primaire returns [Expratt exp] : (i= INTEGER | id= IDENT | tab= tab_elem | ^( FCALL id= IDENT arg= argument_list ) );
    public final Expratt primaire() throws RecognitionException {
        Expratt exp = null;

        CommonTree i=null;
        CommonTree id=null;
        TableAtt tab = null;

        Expratt arg = null;


        exp = null;
        try {
            // vslTree.g:435:3: (i= INTEGER | id= IDENT | tab= tab_elem | ^( FCALL id= IDENT arg= argument_list ) )
            int alt13=4;
            switch ( input.LA(1) ) {
            case INTEGER:
                {
                alt13=1;
                }
                break;
            case IDENT:
                {
                alt13=2;
                }
                break;
            case ARELEM:
                {
                alt13=3;
                }
                break;
            case FCALL:
                {
                alt13=4;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 13, 0, input);

                throw nvae;
            }

            switch (alt13) {
                case 1 :
                    // vslTree.g:435:5: i= INTEGER
                    {
                    i=(CommonTree)match(input,INTEGER,FOLLOW_INTEGER_in_primaire781); 
                    int ival =Integer.parseInt(i.getText());
                    				 exp = new Expratt(TypeSystem.T_integer, new Code(), new Tokatt(ival));

                    }
                    break;
                case 2 :
                    // vslTree.g:438:5: id= IDENT
                    {
                    id=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_primaire794); 

                    				Tokatt tok = tabSymboles.Lookup(id.getText());
                    				if(tok==null && tok.scope == tabSymboles.getScope())
                    				{
                    					System.err.println("la variable n'existe pas");
                    					System.exit(1);
                    				}
                    				else
                    				{
                    					Code c = new Code();
                    					Tokatt temp = SymbDistrib.newTemp();
                    					exp = new Expratt(tok.type,c,tok);
                    				}
                    			

                    }
                    break;
                case 3 :
                    // vslTree.g:453:11: tab= tab_elem
                    {
                    pushFollow(FOLLOW_tab_elem_in_primaire813);
                    tab=tab_elem();

                    state._fsp--;


                    				Tokatt tok = tabSymboles.Lookup(tab.ident.name);
                    				if(tok==null && tok.scope == tabSymboles.getScope())
                    				{
                    					System.err.println("le tableau n'existe pas");
                    					System.exit(1);
                    				}
                    				else
                    				{
                    					Code c = new Code();
                    					exp = new Expratt(tok.type,c,tab.ident);
                    				}
                    			

                    }
                    break;
                case 4 :
                    // vslTree.g:467:5: ^( FCALL id= IDENT arg= argument_list )
                    {
                    match(input,FCALL,FOLLOW_FCALL_in_primaire825); 

                    match(input, Token.DOWN, null); 
                    id=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_primaire829); 
                    pushFollow(FOLLOW_argument_list_in_primaire833);
                    arg=argument_list();

                    state._fsp--;


                    match(input, Token.UP, null); 
                           
                    				Tokatt tok = tabSymboles.Lookup(id.getText());
                    				Tokatt tok2;
                    				Inst3a in;
                    				
                    				if(tok==null)
                    				{
                    					System.err.println("la fonction n'existe pas");
                    					System.exit(1);
                    				}
                    				else
                    				{
                    					Code c = new Code();
                    					tok2 = new Tokatt(id.getText());
                    					Tokatt temp = SymbDistrib.newTemp();

                    					in = new Inst3a(Inst3a.TAC_VAR, temp, null, null);
                    					c.append(new Code(in));
                    					in = new Inst3a(Inst3a.TAC_ARG, arg.place, null, null);
                    					c.append(new Code(in));
                    					in = new Inst3a(Inst3a.TAC_CALL, null, tok, null);
                    					c.append(new Code(in));
                    					in = new Inst3a(Inst3a.TAC_COPY, temp, tok, null);
                    					c.append(new Code(in));
                    					exp = new Expratt(tok.type,c,temp);
                    				}
                    			

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return exp;
    }
    // $ANTLR end "primaire"


    // $ANTLR start "argument_list"
    // vslTree.g:499:1: argument_list returns [Expratt e] : (exp= expression )+ ;
    public final Expratt argument_list() throws RecognitionException {
        Expratt e = null;

        Expratt exp = null;


        e=null;
        try {
            // vslTree.g:501:3: ( (exp= expression )+ )
            // vslTree.g:501:5: (exp= expression )+
            {
            // vslTree.g:501:5: (exp= expression )+
            int cnt14=0;
            loop14:
            do {
                int alt14=2;
                int LA14_0 = input.LA(1);

                if ( (LA14_0==FCALL||LA14_0==ARELEM||LA14_0==IDENT||(LA14_0>=PLUS && LA14_0<=INTEGER)) ) {
                    alt14=1;
                }


                switch (alt14) {
            	case 1 :
            	    // vslTree.g:501:6: exp= expression
            	    {
            	    pushFollow(FOLLOW_expression_in_argument_list873);
            	    exp=expression();

            	    state._fsp--;

            	    Code c = Code.genArgList(exp);e = new Expratt(exp.type, c, exp.place);

            	    }
            	    break;

            	default :
            	    if ( cnt14 >= 1 ) break loop14;
                        EarlyExitException eee =
                            new EarlyExitException(14, input);
                        throw eee;
                }
                cnt14++;
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return e;
    }
    // $ANTLR end "argument_list"


    // $ANTLR start "print_list"
    // vslTree.g:505:1: print_list returns [Code c] : p1= print_item (p2= print_item )* ;
    public final Code print_list() throws RecognitionException {
        Code c = null;

        Code p1 = null;

        Code p2 = null;


        c=new Code();
        try {
            // vslTree.g:507:3: (p1= print_item (p2= print_item )* )
            // vslTree.g:507:5: p1= print_item (p2= print_item )*
            {
            pushFollow(FOLLOW_print_item_in_print_list905);
            p1=print_item();

            state._fsp--;

            // vslTree.g:507:19: (p2= print_item )*
            loop15:
            do {
                int alt15=2;
                int LA15_0 = input.LA(1);

                if ( (LA15_0==FCALL||LA15_0==ARELEM||LA15_0==IDENT||(LA15_0>=PLUS && LA15_0<=TEXT)) ) {
                    alt15=1;
                }


                switch (alt15) {
            	case 1 :
            	    // vslTree.g:507:20: p2= print_item
            	    {
            	    pushFollow(FOLLOW_print_item_in_print_list910);
            	    p2=print_item();

            	    state._fsp--;


            	    }
            	    break;

            	default :
            	    break loop15;
                }
            } while (true);


            					c=Code.genPrintList(p1,p2);
            			

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "print_list"


    // $ANTLR start "print_item"
    // vslTree.g:513:1: print_item returns [Code c] : (t= TEXT | exp= expression );
    public final Code print_item() throws RecognitionException {
        Code c = null;

        CommonTree t=null;
        Expratt exp = null;


        c= new Code();
        try {
            // vslTree.g:515:3: (t= TEXT | exp= expression )
            int alt16=2;
            int LA16_0 = input.LA(1);

            if ( (LA16_0==TEXT) ) {
                alt16=1;
            }
            else if ( (LA16_0==FCALL||LA16_0==ARELEM||LA16_0==IDENT||(LA16_0>=PLUS && LA16_0<=INTEGER)) ) {
                alt16=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 16, 0, input);

                throw nvae;
            }
            switch (alt16) {
                case 1 :
                    // vslTree.g:515:5: t= TEXT
                    {
                    t=(CommonTree)match(input,TEXT,FOLLOW_TEXT_in_print_item942); 
                    	
                    				c=Code.genPrintText(t.getText());
                    			

                    }
                    break;
                case 2 :
                    // vslTree.g:519:5: exp= expression
                    {
                    pushFollow(FOLLOW_expression_in_print_item955);
                    exp=expression();

                    state._fsp--;


                    				c=Code.genPrintExpr(exp);
                    			

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "print_item"


    // $ANTLR start "read_list"
    // vslTree.g:525:1: read_list returns [Code c] : (r= read_item )+ ;
    public final Code read_list() throws RecognitionException {
        Code c = null;

        Code r = null;


        c = new Code();
        try {
            // vslTree.g:527:3: ( (r= read_item )+ )
            // vslTree.g:527:5: (r= read_item )+
            {
            // vslTree.g:527:5: (r= read_item )+
            int cnt17=0;
            loop17:
            do {
                int alt17=2;
                int LA17_0 = input.LA(1);

                if ( (LA17_0==ARELEM||LA17_0==IDENT) ) {
                    alt17=1;
                }


                switch (alt17) {
            	case 1 :
            	    // vslTree.g:527:6: r= read_item
            	    {
            	    pushFollow(FOLLOW_read_item_in_read_list986);
            	    r=read_item();

            	    state._fsp--;

            	    c.append(r);

            	    }
            	    break;

            	default :
            	    if ( cnt17 >= 1 ) break loop17;
                        EarlyExitException eee =
                            new EarlyExitException(17, input);
                        throw eee;
                }
                cnt17++;
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "read_list"


    // $ANTLR start "read_item"
    // vslTree.g:530:1: read_item returns [Code c] : (id= IDENT | tab= tab_elem );
    public final Code read_item() throws RecognitionException {
        Code c = null;

        CommonTree id=null;
        TableAtt tab = null;


        c = new Code();
        try {
            // vslTree.g:532:3: (id= IDENT | tab= tab_elem )
            int alt18=2;
            int LA18_0 = input.LA(1);

            if ( (LA18_0==IDENT) ) {
                alt18=1;
            }
            else if ( (LA18_0==ARELEM) ) {
                alt18=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 18, 0, input);

                throw nvae;
            }
            switch (alt18) {
                case 1 :
                    // vslTree.g:532:5: id= IDENT
                    {
                    id=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_read_item1015); 

                    				Tokatt L8;
                    				Inst3a i;
                    				Tokatt t2;

                    				t2 = tabSymboles.Lookup(id.getText());		
                    				L8 = new Tokatt("L8",null);

                    			if(t2==null && t2.scope != tabSymboles.getScope())
                    			{
                    				System.err.println("la variable n'existe pas");
                    				System.exit(1);
                    			}
                    			else
                    			{
                    				i = new Inst3a(Inst3a.TAC_CALL, t2, L8, null);
                    				c.append(new Code(i));
                    			}
                    		

                    }
                    break;
                case 2 :
                    // vslTree.g:552:5: tab= tab_elem
                    {
                    pushFollow(FOLLOW_tab_elem_in_read_item1028);
                    tab=tab_elem();

                    state._fsp--;


                    				Tokatt L8;
                    				Inst3a i;
                    				Tokatt t2;

                    				t2 = tab.ident;		
                    				L8 = new Tokatt("L8",null);

                    			if(t2==null && t2.scope != tabSymboles.getScope())
                    			{
                    				System.err.println("la variable n'existe pas");
                    				System.exit(1);
                    			}
                    			else
                    			{
                    				i = new Inst3a(Inst3a.TAC_CALL, t2, L8, null);
                    				c.append(new Code(i));
                    			}
                    		

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "read_item"


    // $ANTLR start "declaration"
    // vslTree.g:574:1: declaration returns [Code c] : ^( DEC (d= dec_item )+ ) ;
    public final Code declaration() throws RecognitionException {
        Code c = null;

        Code d = null;


        c = new Code();
        try {
            // vslTree.g:576:3: ( ^( DEC (d= dec_item )+ ) )
            // vslTree.g:576:5: ^( DEC (d= dec_item )+ )
            {
            match(input,DEC,FOLLOW_DEC_in_declaration1058); 

            match(input, Token.DOWN, null); 
            // vslTree.g:576:11: (d= dec_item )+
            int cnt19=0;
            loop19:
            do {
                int alt19=2;
                int LA19_0 = input.LA(1);

                if ( (LA19_0==ARDEC||LA19_0==IDENT) ) {
                    alt19=1;
                }


                switch (alt19) {
            	case 1 :
            	    // vslTree.g:576:12: d= dec_item
            	    {
            	    pushFollow(FOLLOW_dec_item_in_declaration1063);
            	    d=dec_item();

            	    state._fsp--;

            	     c.append(d); 

            	    }
            	    break;

            	default :
            	    if ( cnt19 >= 1 ) break loop19;
                        EarlyExitException eee =
                            new EarlyExitException(19, input);
                        throw eee;
                }
                cnt19++;
            } while (true);


            match(input, Token.UP, null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "declaration"


    // $ANTLR start "dec_item"
    // vslTree.g:580:1: dec_item returns [Code c] : (id= IDENT | ^( ARDEC id= IDENT it= INTEGER ) );
    public final Code dec_item() throws RecognitionException {
        Code c = null;

        CommonTree id=null;
        CommonTree it=null;

        c = new Code();
        try {
            // vslTree.g:582:3: (id= IDENT | ^( ARDEC id= IDENT it= INTEGER ) )
            int alt20=2;
            int LA20_0 = input.LA(1);

            if ( (LA20_0==IDENT) ) {
                alt20=1;
            }
            else if ( (LA20_0==ARDEC) ) {
                alt20=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 20, 0, input);

                throw nvae;
            }
            switch (alt20) {
                case 1 :
                    // vslTree.g:582:5: id= IDENT
                    {
                    id=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_dec_item1098); 

                    			Code cod;
                    			Inst3a in;
                    			Tokatt tok;
                    			
                    			cod = new Code();

                    			if(tabSymboles.Lookup(id.getText())!=null && tabSymboles.Lookup(id.getText()).scope == tabSymboles.getScope())
                    			{
                    				System.err.println("variable déja existante");
                    				System.exit(1);
                    			}
                    			else
                    			{
                    				tok = new Tokatt(TypeSystem.T_integer,id.getText(),tabSymboles.getScope());
                    				tabSymboles.Insert(id.getText(), tok);
                    				in = new Inst3a(Inst3a.TAC_VAR, tok, null, null);
                    				cod.append(new Code(in));
                    			}
                    		c = cod;
                    		

                    }
                    break;
                case 2 :
                    // vslTree.g:604:14: ^( ARDEC id= IDENT it= INTEGER )
                    {
                    match(input,ARDEC,FOLLOW_ARDEC_in_dec_item1118); 

                    match(input, Token.DOWN, null); 
                    id=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_dec_item1122); 
                    it=(CommonTree)match(input,INTEGER,FOLLOW_INTEGER_in_dec_item1126); 

                    match(input, Token.UP, null); 

                    			Inst3a in;			
                    			Tokatt tok;
                    			int inte = Integer.parseInt(it.getText());
                    			String iden = id.getText();
                    			TypeArray typeTab = new TypeArray(TypeSystem.T_integer, inte);

                    			if(tabSymboles.Lookup(iden)!=null && tabSymboles.Lookup(iden).scope == tabSymboles.getScope())

                    			{
                    				System.err.println("tableau deja existant");
                    				System.exit(1);
                    			}
                    			else
                    			{
                    				tok = new Tokatt(typeTab,iden,tabSymboles.getScope());
                    				tabSymboles.Insert(iden, tok);
                    				in = new Inst3a(Inst3a.TAC_VAR, tok, null, null);
                    				c.append(new Code(in));
                    			}
                    		

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return c;
    }
    // $ANTLR end "dec_item"

    // Delegated rules


    protected DFA7 dfa7 = new DFA7(this);
    static final String DFA7_eotS =
        "\14\uffff";
    static final String DFA7_eofS =
        "\14\uffff";
    static final String DFA7_minS =
        "\1\7\1\2\7\uffff\1\15\2\uffff";
    static final String DFA7_maxS =
        "\1\42\1\2\7\uffff\1\21\2\uffff";
    static final String DFA7_acceptS =
        "\2\uffff\1\3\1\4\1\5\1\6\1\7\1\10\1\11\1\uffff\1\1\1\2";
    static final String DFA7_specialS =
        "\14\uffff}>";
    static final String[] DFA7_transitionS = {
            "\1\7\1\10\21\uffff\1\1\1\2\1\3\1\4\1\5\3\uffff\1\6",
            "\1\11",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "\1\13\3\uffff\1\12",
            "",
            ""
    };

    static final short[] DFA7_eot = DFA.unpackEncodedString(DFA7_eotS);
    static final short[] DFA7_eof = DFA.unpackEncodedString(DFA7_eofS);
    static final char[] DFA7_min = DFA.unpackEncodedStringToUnsignedChars(DFA7_minS);
    static final char[] DFA7_max = DFA.unpackEncodedStringToUnsignedChars(DFA7_maxS);
    static final short[] DFA7_accept = DFA.unpackEncodedString(DFA7_acceptS);
    static final short[] DFA7_special = DFA.unpackEncodedString(DFA7_specialS);
    static final short[][] DFA7_transition;

    static {
        int numStates = DFA7_transitionS.length;
        DFA7_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA7_transition[i] = DFA.unpackEncodedString(DFA7_transitionS[i]);
        }
    }

    class DFA7 extends DFA {

        public DFA7(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 7;
            this.eot = DFA7_eot;
            this.eof = DFA7_eof;
            this.min = DFA7_min;
            this.max = DFA7_max;
            this.accept = DFA7_accept;
            this.special = DFA7_special;
            this.transition = DFA7_transition;
        }
        public String getDescription() {
            return "233:1: statement returns [Code c] : ( ^( ASSIGN_KW id= IDENT exp= expression ) | ^( ASSIGN_KW tab= tab_elem exp= expression ) | ^( RETURN_KW exp= expression ) | ^( PRINT_KW p= print_list ) | ^( READ_KW r= read_list ) | ^( IF_KW exp1= expression s1= statement (s2= statement )? ) | ^( WHILE_KW expr= expression s= statement ) | ^( FCALL_S id= IDENT arg= argument_list ) | b= block );";
        }
    }
 

    public static final BitSet FOLLOW_PROG_in_program72 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_unite_in_program77 = new BitSet(new long[]{0x0000000000110008L});
    public static final BitSet FOLLOW_FUNC_KW_in_unite114 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_type_in_unite118 = new BitSet(new long[]{0x0000000000020000L});
    public static final BitSet FOLLOW_IDENT_in_unite122 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_param_list_in_unite126 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_CORPS_in_unite129 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_statement_in_unite133 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_PROTO_KW_in_unite147 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_type_in_unite151 = new BitSet(new long[]{0x0000000000020000L});
    public static final BitSet FOLLOW_IDENT_in_unite155 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_param_list_in_unite159 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_INT_KW_in_type188 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_VOID_KW_in_type199 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_PARAM_in_param_list229 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_param_in_param_list233 = new BitSet(new long[]{0x0000000000021008L});
    public static final BitSet FOLLOW_IDENT_in_param265 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ARRAY_in_param284 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_IDENT_in_param288 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ASSIGN_KW_in_statement321 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_IDENT_in_statement325 = new BitSet(new long[]{0x00000F8000022200L});
    public static final BitSet FOLLOW_expression_in_statement329 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ASSIGN_KW_in_statement342 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_tab_elem_in_statement346 = new BitSet(new long[]{0x00000F8000022200L});
    public static final BitSet FOLLOW_expression_in_statement350 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_RETURN_KW_in_statement364 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_statement368 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_PRINT_KW_in_statement381 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_print_list_in_statement385 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_READ_KW_in_statement398 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_read_list_in_statement402 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_IF_KW_in_statement415 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_statement419 = new BitSet(new long[]{0x000000047C000180L});
    public static final BitSet FOLLOW_statement_in_statement423 = new BitSet(new long[]{0x000000047C000188L});
    public static final BitSet FOLLOW_statement_in_statement428 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_WHILE_KW_in_statement443 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_statement447 = new BitSet(new long[]{0x000000047C000180L});
    public static final BitSet FOLLOW_statement_in_statement451 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_FCALL_S_in_statement468 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_IDENT_in_statement472 = new BitSet(new long[]{0x00000F8000022200L});
    public static final BitSet FOLLOW_argument_list_in_statement476 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_block_in_statement490 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_BLOCK_in_block520 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_declaration_in_block524 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_suit_inst_in_block529 = new BitSet(new long[]{0x0000000000004008L});
    public static final BitSet FOLLOW_BLOCK_in_block544 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_suit_inst_in_block549 = new BitSet(new long[]{0x0000000000004008L});
    public static final BitSet FOLLOW_ARELEM_in_tab_elem581 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_IDENT_in_tab_elem585 = new BitSet(new long[]{0x00000F8000022200L});
    public static final BitSet FOLLOW_expression_in_tab_elem589 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_INST_in_suit_inst622 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_statement_in_suit_inst630 = new BitSet(new long[]{0x000000047C000188L});
    public static final BitSet FOLLOW_PLUS_in_expression661 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression665 = new BitSet(new long[]{0x00000F8000022200L});
    public static final BitSet FOLLOW_expression_in_expression670 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_MOINS_in_expression683 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression687 = new BitSet(new long[]{0x00000F8000022200L});
    public static final BitSet FOLLOW_expression_in_expression691 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_MUL_in_expression704 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression708 = new BitSet(new long[]{0x00000F8000022200L});
    public static final BitSet FOLLOW_expression_in_expression713 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_DIV_in_expression726 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expression_in_expression730 = new BitSet(new long[]{0x00000F8000022200L});
    public static final BitSet FOLLOW_expression_in_expression735 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_primaire_in_expression751 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_INTEGER_in_primaire781 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IDENT_in_primaire794 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_tab_elem_in_primaire813 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FCALL_in_primaire825 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_IDENT_in_primaire829 = new BitSet(new long[]{0x00000F8000022200L});
    public static final BitSet FOLLOW_argument_list_in_primaire833 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_expression_in_argument_list873 = new BitSet(new long[]{0x00000F8000022202L});
    public static final BitSet FOLLOW_print_item_in_print_list905 = new BitSet(new long[]{0x00001F8000022202L});
    public static final BitSet FOLLOW_print_item_in_print_list910 = new BitSet(new long[]{0x00001F8000022202L});
    public static final BitSet FOLLOW_TEXT_in_print_item942 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_expression_in_print_item955 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_read_item_in_read_list986 = new BitSet(new long[]{0x0000000000022002L});
    public static final BitSet FOLLOW_IDENT_in_read_item1015 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_tab_elem_in_read_item1028 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_DEC_in_declaration1058 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_dec_item_in_declaration1063 = new BitSet(new long[]{0x0000000000020408L});
    public static final BitSet FOLLOW_IDENT_in_dec_item1098 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ARDEC_in_dec_item1118 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_IDENT_in_dec_item1122 = new BitSet(new long[]{0x0000080000000000L});
    public static final BitSet FOLLOW_INTEGER_in_dec_item1126 = new BitSet(new long[]{0x0000000000000008L});

}